﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;

public partial class NewsforUSER : System.Web.UI.Page
{
    private string strconn;
    SqlCommand comm;
    SqlConnection conn;
    DataSet ds;
    SqlDataAdapter da;


    protected void Page_Load(object sender, EventArgs e)
    {
        strconn = "Server = localhost;database=photofpt;trusted_connection=true";
        conn = new SqlConnection(strconn);
        ds = new DataSet();
        if (!IsPostBack)
            bindproducttogridview();
    }

    protected void bindproducttogridview()
    {
        try
        {
            if (conn.State == ConnectionState.Closed)
                conn.Open();
            comm = new SqlCommand("deNews", conn);
            comm.CommandType = CommandType.StoredProcedure;
            da = new SqlDataAdapter(comm);
            da.Fill(ds);
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }
        catch (SqlException ex)
        {
            throw new Exception(ex.Message);
        }
        finally
        {
            conn.Close();
        }
    }
}